from django.http.response import HttpResponse
from django.shortcuts import render
from django.views import View
# Create your views here.

class MyView(View):
    def get(self, request):
        return HttpResponse('hello->get')

    def post(self, request):
        return HttpResponse('hello->post')

    def put(self, request):
        return HttpResponse('hello->put')

    def delete(self, request):
        return HttpResponse('hello->delete')

    def patch(self, request):
        return HttpResponse('hello->patch')

class GoodView(View):
    def get(self, request):
        data = [
            {"id": 1, "name": "zhangsan", "age": 18},
            {"id": 2, "name": "lisi", "age": 22},
        ]
        return HttpResponse(data)

    def post(self, request):
        data = {"id": 1, "name": "zhangsan", "age": 18},
        return HttpResponse(data)

    def put(self, request):
        data = {"id": 1, "name": "法外狂徒", "age": 99},
        return HttpResponse(data)

    def delete(self, request):
        data = {"msg": "ok"}
        return HttpResponse(data)